
#include "queue.h"
#include <memory.h>

bool enqueueInt(QueueInt* qi, int data) {
    if(qi->count == QUEUE_SIZE)
        return false;

    qi->e[qi->tail % QUEUE_SIZE] = data;
    qi->tail = qi->tail % QUEUE_SIZE + 1;
    qi->count++;
    return true;
}

int dequeueInt(QueueInt* qi) {
    if(!qi->count)
        return NULL_SFD;

    int sfd = qi->e[qi->head];
    qi->e[qi->head] = NULL_DATA;
    qi->head = (qi->head + 1)  % QUEUE_SIZE;
    qi->count--;
    return sfd;
}

void initQueue(QueueInt* qi) {
    memset(qi, NULL_DATA, sizeof(QueueInt));
}
